package servlet;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author 石小俊
 */
public class LifeTwoServlet implements Servlet {

    private ServletConfig config;
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("LifeTwoServlet.init");
        this.config = config;
    }

    @Override
    public ServletConfig getServletConfig() {
        return this.config;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("LifeTwoServlet.service");
        String encoding = getInitParameter("encoding");
        System.out.println("字符集为:"+encoding);
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("LifeTwoServlet.destroy");
    }

    public String getInitParameter(String name){
        return config.getInitParameter(name);
    }
}
